

from multiprocessing import Process
# 进程池
from multiprocessing import Pool
from time import sleep
import os

num = "1"


def run(ok):
    global num
    num = "2"
    print("子进程获取到的num = " + num)


def func():
    # 告诉编译器我这里的num 指的是全局变量num
    global num
    num = "3"
    print("普通方法的num = " + num)


if __name__ == "__main__":

    p = Process(target=run, args=("ok",))

    p.start()

    # 普通方法
    func()

    sleep(2)
    print("主进程获取到的num = " + num)